/*
 * Powered By [rapid-framework]
 * Web Site: http://www.rapid-framework.org.cn
 * Google Code: http://code.google.com/p/rapid-framework/
 * Since 2008 - 2012
 */

package com.tech15.pub.model;

import java.util.List;

import javacommon.base.BaseEntity;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.validation.constraints.Max;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.validator.constraints.Length;

import cn.org.rapid_framework.util.DateConvertUtils;

import com.tech15.core.model.Attach;

/**
 * @author 胡作正 email:zuozhenghu@sina.com
 * @version 1.0
 * @since 1.0
 */


@Entity
@Table(name = "PUB_OFFICE")
public class PubOffice extends BaseEntity implements java.io.Serializable{
	private static final long serialVersionUID = 5454155825314635342L;
	
	//alias
	public static final String TABLE_ALIAS = "办公模版";
	public static final String ALIAS_ID = "id";
	public static final String ALIAS_NAME = "名称主题";
	public static final String ALIAS_LB = "类别";
	public static final String ALIAS_MEMO = "备注";
	public static final String ALIAS_UPTIME = "时间";
	
	//date formats
	public static final String FORMAT_UPTIME = DATE_TIME_FORMAT;
	

	//可以直接使用: @Length(max=50,message="用户名长度不能大于50")显示错误消息
	//columns START
    /**
     * id       db_column: ID 
     */ 	
	@Length(max=32)
	private java.lang.String id;
    /**
     * 名称主题       db_column: NAME 
     */ 	
	@Length(max=200)
	private java.lang.String name;
    /**
     * 类别       db_column: LB 
     */ 	
	
	private java.lang.Integer lb;
    /**
     * 备注       db_column: MEMO 
     */ 	
	@Length(max=600)
	private java.lang.String memo;
    /**
     * 时间       db_column: UPTIME 
     */ 	
	
	private java.util.Date uptime;
	/**
     * 是否受控       db_column: ISAUTH 
     */ 	
	@Max(127)
	private Integer isauth;
	
	  /**
     * 发布部门       db_column: FBBM 
     */ 	
	
	private String fbbm;
    /**
     * 发布人       db_column: FBR 
     */ 	
	
	private Long fbr;
	
	/**
     * 类别2       db_column: LB2 
     */ 	
	private java.lang.Integer lb2;


	public PubOffice(){
	}

	public PubOffice(
		java.lang.String id
	){
		this.id = id;
	}

	

	public void setId(java.lang.String value) {
		this.id = value;
	}
	
	@Id @GeneratedValue(generator="custom-id")
	@GenericGenerator(name="custom-id", strategy = "uuid.hex")
	@Column(name = "ID", unique = true, nullable = false, insertable = true, updatable = true, length = 32)
	public java.lang.String getId() {
		return this.id;
	}
	
	@Column(name = "NAME", unique = false, nullable = true, insertable = true, updatable = true, length = 200)
	public java.lang.String getName() {
		return this.name;
	}
	
	public void setName(java.lang.String value) {
		this.name = value;
	}
	
	@Column(name = "LB", unique = false, nullable = true, insertable = true, updatable = true, length = 8)
	public java.lang.Integer getLb() {
		return this.lb;
	}
	
	public void setLb(java.lang.Integer value) {
		this.lb = value;
	}
	
	@Column(name = "LB2", unique = false, nullable = true, insertable = true, updatable = true, length = 8)
	public java.lang.Integer getLb2() {
		return this.lb2;
	}
	
	public void setLb2(java.lang.Integer value) {
		this.lb2 = value;
	}
	
	@Column(name = "MEMO", unique = false, nullable = true, insertable = true, updatable = true, length = 600)
	public java.lang.String getMemo() {
		return this.memo;
	}
	
	public void setMemo(java.lang.String value) {
		this.memo = value;
	}
	
	@Transient
	public String getUptimeString() {
		return DateConvertUtils.format(getUptime(), FORMAT_UPTIME);
	}
	public void setUptimeString(String value) {
		setUptime(DateConvertUtils.parse(value, FORMAT_UPTIME,java.util.Date.class));
	}
	
	@Column(name = "UPTIME", unique = false, nullable = true, insertable = true, updatable = true, length = 7)
	public java.util.Date getUptime() {
		return this.uptime;
	}
	
	public void setUptime(java.util.Date value) {
		this.uptime = value;
	}
	
	@Column(name = "ISAUTH", unique = false, nullable = true, insertable = true, updatable = true, length = 2)
	public Integer getIsauth() {
		return this.isauth;
	}
	
	public void setIsauth(Integer value) {
		this.isauth = value;
	}
	
	@Column(name = "FBBM", unique = false, nullable = true, insertable = true, updatable = true, length = 50)
	public String getFbbm() {
		return this.fbbm;
	}
	
	public void setFbbm(String value) {
		this.fbbm = value;
	}
	
	@Column(name = "FBR", unique = false, nullable = true, insertable = true, updatable = true, length = 22)
	public Long getFbr() {
		return this.fbr;
	}
	
	public void setFbr(Long value) {
		this.fbr = value;
	}
	
	

	public String toString() {
		return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
			.append("Id",getId())
			.append("Name",getName())
			.append("Lb",getLb())
			.append("Memo",getMemo())
			.append("Uptime",getUptime())
			.toString();
	}
	
	public int hashCode() {
		return new HashCodeBuilder()
			.append(getId())
			.toHashCode();
	}
	
	public boolean equals(Object obj) {
		if(obj instanceof PubOffice == false) return false;
		if(this == obj) return true;
		PubOffice other = (PubOffice)obj;
		return new EqualsBuilder()
			.append(getId(),other.getId())
			.isEquals();
	}
	
	List<Attach> attach;
	private Long userid;
	private String uptimeBegin;
	private String uptimeEnd;
	private Long[] userids;
	private List<PubOfficeAuth> users;
	private String uploadedAttachName;
	
	@Transient
	public String getUploadedAttachName() {
		return uploadedAttachName;
	}

	public void setUploadedAttachName(String uploadedAttachName) {
		this.uploadedAttachName = uploadedAttachName;
	}

	@Transient
	public Long[] getUserids() {
		return userids;
	}

	public void setUserids(Long[] userids) {
		this.userids = userids;
	}

	@Transient
	public List<PubOfficeAuth> getUsers() {
		return users;
	}

	public void setUsers(List<PubOfficeAuth> users) {
		this.users = users;
	}

	@Transient
	public String getUptimeBegin() {
		return uptimeBegin;
	}

	public void setUptimeBegin(String uptimeBegin) {
		this.uptimeBegin = uptimeBegin;
	}

	@Transient
	public String getUptimeEnd() {
		return uptimeEnd;
	}

	public void setUptimeEnd(String uptimeEnd) {
		this.uptimeEnd = uptimeEnd;
	}

	@Transient
	public Long getUserid() {
		return userid;
	}

	public void setUserid(Long userid) {
		this.userid = userid;
	}

	@Transient
	public List<Attach> getAttach() {
		return attach;
	}

	public void setAttach(List<Attach> attach) {
		this.attach = attach;
	}
}

